<template>
	<view class="card-item" @click="tap">
		<view class="card-top-box">
			<view class="orderid">
				采购单号：{{cardinfo.purchaseNo}}
			</view>
			<view class="card-status" :style="{'backgroundColor': cardType== '' ? statusList[cardinfo.status].color : billstatusList[cardinfo.status].color}">
				
				{{cardType == '' ? statusList[cardinfo.status].name : billstatusList[cardinfo.status].name}}
			</view>
		</view>
		<view class="card-content-box">
			<view class="content-box">
				<view class="item-box">
					<view class="title">
						标题：
					</view>
					<view class="value">
						{{cardinfo.title}}
					</view>
				</view>
				<view class="item-box">
					<view class="title" :style="{'color' : gradeList[cardinfo.priority]}">
						{{cardinfo.priority}}级紧急
					</view>
				</view>
			</view>
			<view class="content-box">
				<view class="item-box">
					<view class="title">
						供应商：
					</view>
					<view class="value" style="color:black;">
						{{ cardinfo.shortSupplier ? cardinfo.shortSupplier : cardinfo.supplier }}
					</view>
				</view>
			</view>
			<view class="content-box">
				<view class="item-box">
					<view class="title">
						物料种类：
					</view>
					<view class="value">
						{{cardinfo.materialSort}}
					</view>
				</view>
				<view class="item-box" v-if="cardType == ''">
					<view class="title">
						不含税金额：
					</view>
					<view class="value" style="color:red;">
						￥{{cardinfo.purchaseSum}}
					</view>
				</view>
				<view class="item-box" v-if="cardType == 'bill'">
					<view class="title">
						含税金额：
					</view>
					<view class="value" style="color:red;">
						￥{{cardinfo.gstInclusiveCount}}
					</view>
				</view>
			</view>
			<view class="content-box">
				<view class="item-box">
					<view class="title">
						申请人：
					</view>
					<view class="value">
						{{cardinfo.applyUser}}
					</view>
				</view>
				<view class="item-box">
					<view class="title">
						申请时间：
					</view>
					<view class="value">
						{{cardinfo.applyTime}}
					</view>
				</view>
			</view>
			<view class="content-box">
				<view class="item-box" v-if="cardinfo.projectName">
					<view class="title">
						<text>项目名称：</text>
						<text style="color:#7567be;"></text>
					</view>
					<view class="value">
						{{cardinfo.projectName}}
					</view>
					</view>
					<view class="item-box" v-if="cardinfo.projectLeader">
						<view class="title">
							<text>负责人：</text>
						</view>
						<view class="value">
							{{cardinfo.projectLeader}}
						</view>
					</view>
			</view>
			<view class="content-box">
				<view class="item-box" v-if="cardinfo.projectNo">
					<view class="title">
						<text>项目编号：</text>
					</view>
					<view class="value">
						{{cardinfo.projectNo}}
					</view>
					</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			info:{
				type:Object,
				default:{}
			},
			cardType:{
				type:String,
				default:''
			}
		},
		mounted() {
			let info = this.info;
			info.gstInclusiveCount= parseFloat(info.gstInclusiveCount);
			info.purchaseSum =  parseFloat(info.purchaseSum);
			info.priority = info.priority.substring(0, 1);
			this.cardinfo = info;
		},
		data() {
			return {
				cardinfo:{},
				statusList:[
					{
						name:'待审批',
						color:'#fb3836'
					},
					{
						name:'已审批',
						color:'#64c05b'
					},
					{
						name:'已退回',
						color:'#fb882b'
					},
				],
				billstatusList:[
					{
						name:'待审核',
						color:'#fb3836'
					},
					{
						name:'通过',
						color:'#64c05b'
					},
					{
						name:'未通过',
						color:'#fb3836'
					},
					{
						name:'待接单',
						color:'#fb3836'
					},
					{
						name:'采购中',
						color:'#fb882b'
					},
					{
						name:'被退回',
						color:'#fb882b'
					},
					{},
					{},
					{},
					{},
					{},
					{
						name:'已关闭',
						color:'#adacac'
					},
				],
				gradeList:['','#DA2B55','#F93C33','#FE940A','#F6B45F','#6D7278'],
			}
		},
		methods: {
			tap:function(){
				let info = this.info;
				this.$emit('tapClick',info);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.card-item {
		border-radius: 30rpx;
		background-color: white;
		overflow: hidden;
		margin-bottom: 20rpx;
		box-shadow: -1rpx 1rpx 15rpx #333333;
		.card-top-box {
			background-color: #828282;
			color: white;
			font-size: 24rpx;
			box-sizing: border-box;
			padding: 0 20rpx;
			position: relative;

			.orderid {
				line-height: 80rpx;
				height: 80rpx;
			}

			.card-status {
				background-color: red;
				width: fit-content;
				border-radius: 20rpx;
				padding: 0 20rpx;
				line-height: 60rpx;
				position: absolute;
				right: 20rpx;
				top: 10rpx;
			}
		}

		.card-content-box {
			padding: 20rpx 20rpx;
			box-sizing: border-box;

			.content-box {
				display: flex;
				justify-content: space-between;
				font-size: 26rpx;

				.item-box {
					display: flex;
					line-height: 60rpx;

					.title {
						color: #585858;
					}

					.value {
						color: #7567be;
					}
				}
			}
		}
	}
</style>
